package practice2;

import java.util.Scanner;

public class P8623 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int w =sc.nextInt();    //排号宽度
        int m =sc.nextInt();    //楼号1
        int n =sc.nextInt();    //楼号2

        int x1;       //横坐标
        int x2;
        if(m%w==0){     //能整除时横坐标要减1
            x1=m/w-1;
        }else {
            x1=m/w;
        }
        if(n%w==0){
            x2=n/w-1;
        }else {
            x2=n/w;
        }
        int y1;
        int y2;
        if(x1%2==0){    //横坐标为偶数，顺序排
            y1=m%w-1;
        }else {         //横坐标为奇数，倒叙排
            y1=w-m%w;
        }
        if(x2%2==0){    //横坐标为偶数，顺序排
            y2=n%w-1;
        }else {         //横坐标为奇数，倒叙排
            y2=w-n%w;
        }
        int ans = Math.abs(x2-x1)+Math.abs(y2-y1);
        System.out.println(ans);
    }
}
